<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
	template="template.xhtml">

	<ui:define name="content">
	
		<h:panelGroup rendered="#{not homeBean.inUserPage}">
			<h1>#{homeBean.homeUser.name} #{homeBean.homeUser.surname}</h1>
		</h:panelGroup>

		<h:panelGroup rendered="#{homeBean.inUserPage}">
			<h1>Welcome #{homeBean.homeUser.name}</h1>
		</h:panelGroup>

		<br/>

		<h:form>
			<p:panelGrid columns="2" style="width:100%">
				<p:panel style="width:585px" header="User Info">

					<h:panelGroup style="width:100%" id="userInfoGroup">

						<p:inputTextarea value="#{homeBean.userInfoText}"
							id="UserInfoTextBox" rendered="#{homeBean.editUserInfo}"
							cols="50" rows="5">
						</p:inputTextarea>

						<p:commandButton id="UserInfoSubmit"
							rendered="#{homeBean.editUserInfo}"
							action="#{homeBean.setUserInfoFonk}"
							update="userInfoGroup aboutMeGroup" value="Submit">
						</p:commandButton>


						<p>#{homeBean.homeUser.userInfo}</p>

						<p:commandButton rendered="#{homeBean.inUserPage}"
							update="userInfoGroup aboutMeGroup"
							action="#{homeBean.editUserInfoFonk}" value="Edit"></p:commandButton>


					</h:panelGroup>
				</p:panel>

				<p:panel style="width:585px" header="About me">


					<h:panelGroup style="width:100%" id="aboutMeGroup">

						<p:inputTextarea value="#{homeBean.aboutMe}" id="AboutMeTextBox"
							rendered="#{homeBean.editAboutMe}" cols="50" rows="5">
						</p:inputTextarea>

						<p:commandButton id="AboutMeSubmit"
							rendered="#{homeBean.editAboutMe}"
							action="#{homeBean.setAboutMeFonk}"
							update="aboutMeGroup userInfoGroup" value="Submit">
						</p:commandButton>


						<p>#{homeBean.homeUser.aboutMe}</p>

						<p:commandButton rendered="#{homeBean.inUserPage}"
							update="aboutMeGroup userInfoGroup"
							action="#{homeBean.editAboutMeFonk}" value="Edit"></p:commandButton>

					</h:panelGroup>
				</p:panel>
			</p:panelGrid>
		</h:form>

		<p:panelGrid style="width:100%" columns="2">
			<p:panel style="width:585px;" header="Tags">
				<p:dataList var="tag" value="#{homeBean.tags}" paginator="true"
					rowsPerPageTemplate="10" rows="10" emptyMessage="No tags"
					type="definition" id="tagList">
					<ul>
						<li>#{tag}</li>
					</ul>
				</p:dataList>
			</p:panel>

			<p:panel style="width:585px" header="Badges">
				<p:dataList var="bad" value="#{homeBean.badges}" paginator="true"
					rowsPerPageTemplate="10" rows="10" emptyMessage="No badges"
					type="definition" id="badgeList">
					<ul>
						<li>#{bad.badgeName}</li>
					</ul>
				</p:dataList>
			</p:panel>
		</p:panelGrid>

		<p:panelGrid columns="2">
			<p:panel style="width:585px" header="Comments">

				<p:dataList var="comment" value="#{homeBean.comments}"
					paginator="true" rowsPerPageTemplate="10" rows="10"
					emptyMessage="No comments" type="definition" id="commentList">

					<table>
						<tr>
							<td style="width: 380px;">#{comment.comment}</td>
							<td style="width: 120px;">#{comment.place.placeName}</td>
							<td style="width: 50px;"><a target="_blank"
								href="/ourcity/details.xhtml?placeId=#{comment.place.placeID}">See
									More</a></td>
						</tr>
					</table>

				</p:dataList>
			</p:panel>

			<p:panel style="width:585px" header="Favourite Places">
				<p:dataList var="place" value="#{homeBean.favouritePlaces}"
					paginator="true" rowsPerPageTemplate="10" rows="10"
					emptyMessage="No liked places" type="definition" id="placeList">
					<ul>
						<li>#{place.placeName}</li>
					</ul>
				</p:dataList>
			</p:panel>
		</p:panelGrid>
	</ui:define>

</ui:composition>
